<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    request.setAttribute("basePath",basePath);
%>
<!DOCTYPE>
<html>
<head>
    <title>明细信息</title>
    <%@ include file="/resources/js/easyui/taglibs.jsp"%>
    <%@ include file="/resources/js/easyui/_easyui.jsp"%>
    <%@ include file="/resources/js/easyui/_message.jsp"%>
    <%@ include file="/resources/js/easyui/_viewJS.jsp"%>
</head>

<body class="easyui-layout">
    <form name="editform" method="post" id ="editform">
        <table class="tableForm" style="width: 100%;">
            <tr>
                <th align="right" valign="top"><span class="redStart">*</span><label>联系人：</label></th>
                <td><input class="easyui-validatebox easyui-textbox" name="linkman" value="${place.linkman}" style="width:200px" data-options="required:true" /></td>
            </tr>

            <tr>
                <th align="right" valign="top"><span class="redStart">*</span><label>电话：</label></th>
                <td><input class="easyui-validatebox easyui-textbox" name="tele" value="${place.tele}" style="width:200px" data-options="required:true,validType:'mobile'" /></td>
            </tr>

            <tr>
                <th align="right" valign="top"><span class="redStart">*</span><label>地址：</label></th>
                <td><input class="easyui-validatebox easyui-textbox" name="address" value="${place.address}" style="width:200px" data-options="required:true" /></td>
            </tr>

            <tr>
                <th align="right" valign="top"><span class="redStart">*</span><label>设为默认地址：</label></th>
                <td>
                    <label for="rd1" style="width: 45px;margin-left: 5px;">
                        <input type="radio" name="defaultaddress" id="rd1" value="1" ${place.defaultaddress == 1?"checked":"" } style="margin-right: 5px" />是
                    </label>
                    <label for="rd2" style="width: 45px;">
                        <input type="radio" name="defaultaddress" id="rd2" value="0" ${place.defaultaddress == 0?"checked":"" }  style="margin-right: 5px" />否
                    </label>
                </td>
            </tr>

            <tr>
                <th align="right" valign="top"><span class="redStart">*</span><label>状态：</label></th>
                <td>
                    <label for="rd3" style="width: 45px;margin-left: 5px;">
                        <input type="radio" name="state" id="rd3" value="1" ${place.state == 1?"checked":"" } style="margin-right: 5px" />有效
                    </label>
                    <label for="rd4" style="width: 45px;">
                        <input type="radio" name="state" id="rd4" value="0" ${place.state == 0?"checked":"" } style="margin-right: 5px" />无效
                    </label>
                </td>
            </tr>

            <tr>
                <th align="right" valign="top"><span class="redStart">*</span><label>场地类型：</label></th>
                <td>
                    <select id="queryPlaceTypeId" name="placetypeid" class="easyui-combogrid" style="width: 200px;"
                            data-options="editable:false,
                                    required:true,
                                    url:'${basePath}web/placeType/list.json',
                                    panelWidth:420,pagination:true,method:'post',pageSize:5,pageList:[5],
                                    panelHeight:230,
                                    idField: 'placetypeid',
                                    textField: 'placetypename',
                                    queryParams : {
                                        placeTypeName : function(){return $('#placeTypeName').val();}
                                    },
                                    columns: [[
                                        {field:'placetypeid',title:'id',hidden:'true'},
                                        {field:'placetypename',title:'类型名称',width:100,align:'center'},
                                        {field:'placetypeename',title:'类型英文名称',width:100,align:'center'}
                                    ]],
                                    fitColumns: true,
                                    toolbar:'#placetype_search'">
                    </select>
                    <div id="placetype_search" style="height: 40px;padding-top: 5px;">
                        <table>
                            <tr>
                                <td><lable style="margin-left:5px">类型名称:</lable></td>
                                <td>
                                    <input id="placeTypeName" type="text" style="width: 100px;" class="easyui-textbox" />
                                </td>
                                <td><a href="javascript:void(0)" style="margin-left:5px" class="easyui-linkbutton" iconCls="icon-search" id="queryPlaceTypeBtn">查询</a></td>
                            </tr>
                        </table>
                    </div>
                </td>
            </tr>

        </table>
        <input type="hidden" name="placetypeid" value="${place.placeid}" />
    </form>
<script type="application/javascript">

    function edit(){
        if($("#editform").form('validate')){
            $.ajax({
                url:'${basePath}web/placeType/edit',
                type : 'POST',
                data : $("#editform").serialize(),
                async : false, //默认为true 异步
                traditional:true,
                error: function (response) {
                    ViewHelper.func.ajaxErrorMessage(response);
                },
                success: function (ret) {
                    if(ret.result) {
                        $.messager.alert('提示信息！',ret.info,'info');
                        parent.view.closeEditWin(1);
                        $("#editform").form('clear');
                    }else{
                        $.messager.alert('提示','保存失败!','error');
                    }
                }
            });
        }
    }

    $(function() {

        var placetypeid = '${place.placetypeid}';

        $('#queryPlaceTypeId').combogrid('setValue',placetypeid);
    });

    $('#queryPlaceTypeBtn').click(function(){
        $('#queryPlaceTypeId').combogrid('grid').datagrid('load',{
            placeTypeName : function(){return $('#placeTypeName').val();}
        });
    });

    $.extend($.fn.validatebox.defaults.rules, {
        mobile: {
            validator: function(value, param) {
                return /(^([0\+]\d{2,3})\d{3,4}\-\d{3,8}$)|(^([0\+]\d{2,3})\d{3,4}\d{3,8}$)|(^([0\+]\d{2,3}){0,1}13\d{9}$)|(^\d{3,4}\d{3,8}$)|(^\d{3,4}\-\d{3,8}$)/.test(value);
            },
            message: '请输入正确的联系电话或手机号码'
        }

    });

</script>
</body>
</html>
